import 'package:guochaoapp/model/wechatpay_entity.dart';

wechatpayEntityFromJson(WechatpayEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new WechatpayData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> wechatpayEntityToJson(WechatpayEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

wechatpayDataFromJson(WechatpayData data, Map<String, dynamic> json) {
	if (json['paymentNo'] != null) {
		data.paymentNo = json['paymentNo'].toString();
	}
	if (json['aliPayParams'] != null) {
		data.aliPayParams = json['aliPayParams'];
	}
	if (json['wxPayParams'] != null) {
		data.wxPayParams = new WechatpayDataWxPayParams().fromJson(json['wxPayParams']);
	}
	if (json['receiptCard'] != null) {
		data.receiptCard = json['receiptCard'];
	}
	if (json['creditPaySuccess'] != null) {
		data.creditPaySuccess = json['creditPaySuccess'];
	}
	if (json['skipPaySuccess'] != null) {
		data.skipPaySuccess = json['skipPaySuccess'];
	}
	return data;
}

Map<String, dynamic> wechatpayDataToJson(WechatpayData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['paymentNo'] = entity.paymentNo;
	data['aliPayParams'] = entity.aliPayParams;
	if (entity.wxPayParams != null) {
		data['wxPayParams'] = entity.wxPayParams.toJson();
	}
	data['receiptCard'] = entity.receiptCard;
	data['creditPaySuccess'] = entity.creditPaySuccess;
	data['skipPaySuccess'] = entity.skipPaySuccess;
	return data;
}

wechatpayDataWxPayParamsFromJson(WechatpayDataWxPayParams data, Map<String, dynamic> json) {
	if (json['appid'] != null) {
		data.appid = json['appid'].toString();
	}
	if (json['noncestr'] != null) {
		data.noncestr = json['noncestr'].toString();
	}
	if (json['package'] != null) {
		data.package = json['package'].toString();
	}
	if (json['partnerid'] != null) {
		data.partnerid = json['partnerid'].toString();
	}
	if (json['prepayid'] != null) {
		data.prepayid = json['prepayid'].toString();
	}
	if (json['sign'] != null) {
		data.sign = json['sign'].toString();
	}
	if (json['timestamp'] != null) {
		data.timestamp = json['timestamp'] is String
				? int.tryParse(json['timestamp'])
				: json['timestamp'].toInt();
	}
	return data;
}

Map<String, dynamic> wechatpayDataWxPayParamsToJson(WechatpayDataWxPayParams entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['appid'] = entity.appid;
	data['noncestr'] = entity.noncestr;
	data['package'] = entity.package;
	data['partnerid'] = entity.partnerid;
	data['prepayid'] = entity.prepayid;
	data['sign'] = entity.sign;
	data['timestamp'] = entity.timestamp;
	return data;
}